﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TestEnvirementCL.POCO;
using TestEnvirementCL.Concrete;
using System.Reflection;

namespace TestEnvirementMVC.Controllers
{ 
    public class AdvertisementController : Controller
    {
        private EFDbContext db = new EFDbContext();

        //
        // GET: /Advertisement/

        public ActionResult Index()
        {
          var sports = db.Sports.ToList<Sport>();
          var advertisements = db.Advertisements.ToList<Advertisement>();

          MyChart test = new MyChart();
          String startupPath = Assembly.GetAssembly(typeof(MyChart)).Location;
         
          test.initialiseDataSerieArray(sports.Count);
          for (int i =0;i< sports.Count;i++){
            test.countPerName[i] = test.nieuweRij(sports[i].Name, sports[i].Advertisements.Count);
          }
          
          ViewBag.ListSport = test.countPerName;
          ViewBag.ListAdvertisements = advertisements;
          ViewBag.ListSports = sports;
          ViewBag.Message = "Google Charts Graphs";

          return View();
        }

        //
       
    }
}